 <%@ taglib prefix="s" uri="/struts-tags"%> 
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
 <link href="../../../js/thickbox.css" rel="stylesheet" type="text/css" />
      <script src="../../../js/jquery-1.5.min.js" type="text/javascript"></script>
      <script src="../../../js/jqtool.js" type="text/javascript"></script>
      <script src="../../../js/ui.js" type="text/javascript"></script>
      <script src="../../../js/thickbox-compressed.js" type="text/javascript"></script>
		<script src="../../../js/jqui/jquery-1.2.6.min.js" type="text/javascript"></script>
 	   <link href="../../../css/Public.css"type="text/css" rel="stylesheet" />
       <link href="../../../css/PublicEdit.css"type="text/css" rel="stylesheet" /> 
       	<script language="javascript" src="../../../js/dateselect.js"></script>
<title>新增版本 </title>
<style>
.gonggao{
    position:absolute;
    top:80px;
    left:200px;
    width:430px;
    height:300px;
    border:1px solid #993300;
    background-color:#ffffff;
}
.gonggao h1{
    line-height:50px;
    font-size:24px;
    font-family:"黑体";
    font-weight:bold;
    text-align:center;
}
.gonggao div{
    line-height:30px;
    font-size:18px;
    font-family:"黑体";
    text-align:center;
    color:#993300;
}
.gonggao div a,.gonggao div a:visited{
    color:#993300;
}
</style>

<script type="text/javascript">
			function checkData()
			{			
					 var apkinfo_version= window.document.getElementById("apkinfo_version").value;	
					  if(apkinfo_version==null||apkinfo_version=='')
			       		 {
			       				 alert("请输入版本号！");	
					       			window.document.getElementById("apkinfo_version").focus();
								    window.event.returnValue = false;
								    return;		
			       		 }		
			       		 var array=apkinfo_version.split(".");	
			       		 if(array==null||array.length==0)
			       		 {		       		
				        		alert("版本号只能包含数字和符号！例如：1.0.0.1");
				        	 	window.document.getElementById("apkinfo_version").focus();
				           	 	window.event.returnValue = false;
				            	return;
			       		 }		       		
							for(var i=0;i<array.length;i++)
							{
							  	if(!isInt(array[i]))  
					        	{
					        		alert("版本号只能包含数字和符号！例如：1.0.0.1");
					        	 	window.document.getElementById("apkinfo_version").focus();
					           	 	window.event.returnValue = false;
					            	return;
					        	} 
							}
			       		 			       		
			       		
			        	var ss='false';
			        	$.ajaxSettings.async = false;
							  $.getJSON("/admin/json/isexsistApkversion?vt=1&ver=" + apkinfo_version+"&rnd="+Math.random(), function(data) 
							  {
								  	 if(data.str=='Y')
								  	 {
								  		alert("该版本号已经存在！");
								  		ss="true";
								 	}
								}); 
							if(ss=='true')
							{
							window.event.returnValue = false;
							return ;
							}  
			       		
			       		 var reso= window.document.getElementById("reso").value;
			       		 if(reso==null||reso=='')
			       		 {
			       				 alert("请选择文件上传！");	
					       			window.document.getElementById("reso").focus();
								    window.event.returnValue = false;
								    return;		
			       		 }
			       		 var extname = reso.substring(reso.lastIndexOf(".")+1,reso.length);
							   extname = extname.toLowerCase();//处理了大小写
							    if(extname!= "apk")
							    {
							     alert("只能上传apk格式的文件！");
							     window.event.returnValue = false;
								    return;	
							    }
			       		 
					/*var chks=document.getElementsByTagName("input");
				     var len=chks.length;		   
				     for (i=0; i<len; i++) 
				     {
				        var cur=chks[i];
				        if(cur.type=="file")
				            {  				            
				            	var fv=cur.value;				           
				            	if(fv==null||fv=='')
				            	{		
					            	alert("请选择文件上传！");	
					       			window.document.getElementById(cur.id).focus();
								    window.event.returnValue = false;
								    return;				            	
				            	}
				            	else
				            	{
				            		
				            	}
					        }       
				    }		*/
			       bbform.submit();			        		      
			}	
			function isInt(str)
			{
				//var reg = /^(-|\+)?\d+$/ ;
				if(str==0)return true;
				var reg = /^[1-9]\d*$/;	
				return reg.test(str);			
			}		
 </script>		
</head>
<body >
<form action="saveapk" name="bbform" id="bbform" method="post" enctype="multipart/form-data">

				<div>
		                <div class="l_f_top">
		                    <div class="l_f_top_left_div"><img alt="" src="../../../images/tb.gif" width="16" height="16" /></div>
		                    <div class="l_f_top_right_div">新增版本        </div>
		                </div>
		                <div class="l_f_body"> 		                 
		                     <div class="l_f_body_row">
		                        <div class="l_f_body_div1">                            版本号:</div>
		                        <div class="l_f_body_div5">
				                       <input type="text"  name ="apkinfo.version" id="apkinfo_version" style="width:120px" maxlength="7"/>  
					           </div>                      
		                    </div>	 		                   
							<div class="l_f_body_row">
							<div class="l_f_body_div1">APK文件:</div>
								<div class="l_f_body_div5">
								<input type="file" style="width:450px" id="reso" name="reso" />
								</div>
							</div>		                     
		                     <div class="l_f_body_row">
		                        <div class="l_f_body_div1">                              状态:</div>
		                        <div class="l_f_body_div5" >
		               		     <select name="apkinfo.status" id="apkinfo_status" style="width: 120px">
									<option value="0">
										关闭
									</option>								
									<option value="1" selected>
										开放
									</option>							
								</select>
							   </div>
							   </div>
		                     <div class="center l_f_body_foot">			                     
		                       <input type="button" id="button" name="button" class="button2_60" onclick="checkData();"  value="提交"/>		                      
		                      <input type="button" class="button2_60"  onclick="javascript:history.go(-1);" value=" 返回"/>
		                      </div>
		                </div>
			    	</div> 
</form>
</body>
</html>